<template>
    <el-input v-model="time"></el-input>
</template>

<script setup>
// 自定义Ref加防抖
import { ref, onMounted, onBeforeUnmount, nextTick, customRef } from 'vue';
const myRef = (value,delay = 200) => {
  return customRef((track, trigger) => { 
    let timeout
    return {
      get(){
        track() //通知模板引擎追踪
        return value
      },
      set(newValue){ 
        clearTimeout(timeout)
        timeout = setTimeout(() => {
          value = newValue
          trigger() //通知模板引擎更新
        }, delay)
        console.log('newValue',newValue)
        return newValue
      }
    }
})
}
const time = myRef('2',300)

</script>

<style lang="scss" scoped>
</style>